﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WindowsFormsApplication1.WebTest.WebTestXmlNodes;

namespace WindowsFormsApplication1.WebTest
{
    public class NodeDescriptionPropertiesCollection : Dictionary<string, NodeDescriptionProperties>
    {
        public NodeDescriptionProperties Content
        {
            get
            {
                var result = from collection in Values
                             where collection.WebTestNodeType == NodeDescriptionProperties.WebTestNodeTypes.Content
                             select collection;

                return result.Single();
            }
        }

        public bool HasContent
        {
            get
            {
                var result = from collection in Values
                             where collection.WebTestNodeType == NodeDescriptionProperties.WebTestNodeTypes.Content
                             select collection;

                return result.Count() == 1;
            }
        }

        public Dictionary<string, NodeDescriptionProperties> Attributes
        {
            get
            {
                var result = from collection in Values
                             where collection.WebTestNodeType == NodeDescriptionProperties.WebTestNodeTypes.Attribute
                             select collection;

                return result.ToDictionary(key => key.Name);
            }
        }

        public Dictionary<string, NodeDescriptionProperties> Parameters
        {
            get
            {
                var result = from collection in Values
                             where collection.WebTestNodeType == NodeDescriptionProperties.WebTestNodeTypes.Parameter
                             select collection;

                return result.ToDictionary(key => key.Name);
            }
        }

    }

}
